<!DOCTYPE html>
<html>
<head>
  <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no">
  <meta name="_token" content="{{ csrf_token() }}"/>
  <title后台 系统登录</title>
  <meta name="renderer" content="webkit">
  <script src="/login/jquery-1.11.3.min.js"></script>
  <link href="/login/bootstrap.min.css" rel="stylesheet">
  <style type="text/css">
    html, body { height: 100%; overflow: hidden; }
    body {
        font-family: "Verdana", "Tahoma", "Lucida Grande", "Microsoft YaHei", "Hiragino Sans GB", sans-serif;
        background: url(/login/images/loginbg_01.jpg) no-repeat center center fixed;
        background-size: cover;
    }
    .form-control{height:37px;}
    .main_box{position:absolute; top:45%; left:50%; margin:-200px 0 0 -180px; padding:15px 20px; width:360px; height:auto; min-width:320px; background:#FAFAFA; background:rgba(255,255,255,0.5); box-shadow: 1px 5px 8px #888888; border-radius:6px;}
    .main_box .setting {position: absolute; top: 5px; right: 10px; width: 10px; height: 10px;}
    .main_box .setting a {color: #FF6600;}
    .main_box .setting a:hover {color: #555;}
    .login_msg{height:30px;}
    .input-group >.input-group-addon.code{padding:0;}
    #captcha_img{cursor:pointer;}
    .main_box .logo img{height:35px;}
    @media (min-width: 768px) {
      .main_box {margin-left:-240px; padding:15px 55px; width:480px;}
      .main_box .logo img{height:120px;}
    }
  </style>
</head>
<body>
  <div class="container">
    <div class="main_box">
      <div class="setting"><a href="javascript:;" onclick="choose_bg();" title="更换背景"></a></div>
      <form action="javascript:;" id="login_form" method="post">
        <input id="offset" type="hidden" name="offset" value="">
        <!-- <p class="text-center logo"><img src="/login/logo.png" ></p> -->
        <p class="text-center logo" style="font-size:34px;color:#fff;">后台管理系统</p>
        <div class="login_msg text-center"><font color="red"></font></div>
        <div class="form-group">
          <div class="input-group">
            <span class="input-group-addon" id="sizing-addon-user">账号</span>
            <input type="text" class="form-control" id="j_username" name="user" value="" placeholder="登录账号" aria-describedby="sizing-addon-user">
          </div>
        </div>
        <div class="form-group">
          <div class="input-group">
            <span class="input-group-addon" id="sizing-addon-password">密码</span>
            <input type="password" class="form-control" id="j_password" name="password" placeholder="登录密码" aria-describedby="sizing-addon-password">
          </div>
        </div>
        <div class="form-group">
          <div class="input-group">
            <span class="input-group-addon" id="sizing-addon-password">操作密码</span>
            <input type="password" class="form-control" id="j_checkpass" name="check_pass" placeholder="操作密码" aria-describedby="sizing-addon-password">
          </div>
        </div>
        <!-- <div class="form-group">
          <div class="input-group">
            <span class="input-group-addon" id="sizing-addon-password"><span class="glyphicon glyphicon-exclamation-sign"></span></span>
            <input type="text" class="form-control" id="j_captcha" name="code" placeholder="验证码" aria-describedby="sizing-addon-password">
            <span class="input-group-addon code" id="basic-addon-code"><img id="captcha_img" src="__STATIC__/index/images/captcha.jpg" alt="点击更换" title="点击更换" class="m"></span>
          </div>
        </div> -->
        <div class="text-center">
          <button type="submit" id="login_ok" class="btn btn-primary btn-lg">&nbsp;登&nbsp;录&nbsp;</button>&nbsp;&nbsp;&nbsp;&nbsp;
          <button type="reset" class="btn btn-default btn-lg">&nbsp;重&nbsp;置&nbsp;</button>
        </div>
        <div class="text-center">
          <hr>
          <br>技术支持 <a href="http://abbear.com/" target="_blank">萌熊梦工厂</a>
        </div>
      </form>
    </div>
  </div>
</body>
</html>
<script type="text/javascript">
  $(function(){
    choose_bg();
    // changeCode();
    // $("#captcha_img").click(function(){
    //   changeCode();
    // });
    //登陆
    $("#login_form").submit(function(){
      var issubmit = true;
      var i_index  = 0;
      $(this).find('.form-control').each(function(i){
        if($.trim($(this).val()).length == 0) {
          $(this).css('border', '1px #ff0000 solid');
          issubmit = false;
          if (i_index == 0)
          i_index  = i;
        }
      });
      if(!issubmit){
        $(this).find('.form-control').eq(i_index).focus();
        return false;
      }

      var user = $("#j_username").val();
      var password = $("#j_password").val();
      var check_pass = $("#j_checkpass").val();
      $.ajax({
        url:"{{url('admin/action')}}",
        type: 'post',
        data: {user:user,password:password,check_pass:check_pass},
        dataType: 'json',
        headers: {
          'X-CSRF-TOKEN': $('meta[name="_token"]').attr('content')
        },
        success:function(data){
          if(data['code'] == 1){
            {{--  跳转到首页  --}}
            window.location.href = "{{url('admin') }}";
          }else{
            alert(data['msg']);
          }
        },
        error:function(){
          alert("系统正忙");
        }
      })
      

    })
  })
  //换背景
  function choose_bg(){
    var bg = Math.floor(Math.random() * 9 + 1);
    $('body').css('background-image', 'url(/login/images/loginbg_0'+ bg +'.jpg)');
  }
  //验证码
  // function changeCode(){
  //   //$("#captcha_img").attr("src", "sys/login/getCaptcha?t="+ (new Date().getTime()));
  //   $("#captcha_img").attr("src", "{:captcha_src()}?t="+ (new Date().getTime()));
  // }
</script>